package com.library.circles.service;

import com.library.circles.dao.CirclesDaoImpl;
import com.library.entity.Circles;
import com.library.entity.Staff;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;

@Service
@Transactional(readOnly=false)
public class CirclesServiceImpl {
	
	@Resource
	private CirclesDaoImpl circlesDaoImpl;

	public void addCircles(Circles circles){
		this.circlesDaoImpl.saveCircles(circles);
	}

    @Transactional(readOnly=true)
	public Circles getCirclesById(Integer circlesId)
	{
		return this.circlesDaoImpl.getCirclesById(circlesId);
	}

    @Transactional(readOnly = true)
	public Circles getCirclesByStaff(Staff staff){
		return this.getCirclesById(staff.getCircles().getCirclesId());
	}

	public void updateCircles(Circles circles){
		this.circlesDaoImpl.updateCircle(circles);
	}


	/*删除指定评价记录*/
	public void deleteCircles(int circlesId){
		Circles circles = this.circlesDaoImpl.getCirclesById(circlesId);
		this.circlesDaoImpl.deleteCircles(circles);
    }
}
